package bytestream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class J_Data
{
    public static void main(String args[ ])
    {
        try
        {
            FileOutputStream fout = new FileOutputStream("out.txt");
            int i;
            try (DataOutputStream dfout = new DataOutputStream(fout)) {
                for (i=0; i< 4; i++)
                    dfout.writeInt(i);
            }

            FileInputStream fin= new FileInputStream("out.txt");
            DataInputStream dfin= new DataInputStream(fin);
            for (i=0; i< 4; i++)
                System.out.print(dfin.readInt( ) + ", ");
            dfin.close( );
        }
        catch (Exception e)
        {
            System.err.println("发生异常:" + e);
            e.printStackTrace( );
        } // try-catch结构结束
    } // 方法main结束
} // 类J_Data结束
